# Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.

# CMake lowest version requirement
cmake_minimum_required(VERSION 3.5.1)

# project information
project(acl_execute_leaky_relu)

# Compile options
add_compile_options(-std=c++11)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "../output")

set(INC_PATH $ENV{DDK_PATH})

if (NOT DEFINED ENV{DDK_PATH})
    set(INC_PATH "/usr/local/Ascend/ascend-toolkit/latest")
    message(STATUS "set default INC_PATH: ${INC_PATH}")
else ()
    message(STATUS "env INC_PATH: ${INC_PATH}")
endif()

set(CUST_PKG_PATH_LIST $ENV{ASCEND_CUSTOM_OPP_PATH})
list(GET CUST_PKG_PATH_LIST 0 CUST_PKG_PATH)
string(REPLACE ":" "" CUST_PKG_PATH ${CUST_PKG_PATH})
set(CUST_PKG_PATH "${CUST_PKG_PATH}/op_api")
message(STATUS "env CUST_PKG_PATH: ${CUST_PKG_PATH}")

set(LIB_PATH $ENV{NPU_HOST_LIB})

# Dynamic libraries in the stub directory can only be used for compilation
if (NOT DEFINED ENV{NPU_HOST_LIB})
    set(LIB_PATH "/usr/local/Ascend/ascend-toolkit/latest/acllib/lib64/stub/")
    set(LIB_PATH1 "/usr/local/Ascend/ascend-toolkit/latest/atc/lib64/stub/")
    message(STATUS "set default LIB_PATH: ${LIB_PATH}")
else ()
    message(STATUS "env LIB_PATH: ${LIB_PATH}")
endif()

# Header path
include_directories(
    ${INC_PATH}/runtime/include
    ${INC_PATH}/atc/include
    ${CUST_PKG_PATH}/include
#    /home/ma-user/work/LeakyRelu/LeakyReluFrameworkLaunch/LeakyReluCustom/install/vendors/customize/op_api/include
)


# add host lib path
link_directories(
    ${LIB_PATH}
    ${LIB_PATH1}
    ${CUST_PKG_PATH}/lib
#    /home/ma-user/work/LeakyRelu/LeakyReluFrameworkLaunch/LeakyReluCustom/install/vendors/customize/op_api/lib
)

add_executable(execute_leakyrelu_op
    main.cpp
)

target_link_libraries(execute_leakyrelu_op
    ascendcl
    cust_opapi
    acl_op_compiler
    nnopbase
    stdc++
)

install(TARGETS execute_leakyrelu_op DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
